package cn.ctbu.simple_score_manage.dao;

import cn.ctbu.simple_score_manage.domain.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface IStudentDao extends BaseMapper<Student> {

    /**
     * 通过学生的no查询所修所有课程的信息
     * @param id
     * @return
     */
    @Select("<script>" +"SELECT tb_score.id as `scoreId`,tb_student.id as `studentId`,tb_student.`no` as no,tb_student.`name` as `name`,tb_course.`name` as '课程名',tb_teacher.`name` as '任课教师',tb_score.score as '成绩'" +
            "FROM tb_score,tb_student,tb_course,tb_teacher where tb_student.`no` = tb_score.student_no and tb_score.`course_no` = tb_course.`no`" +
            "and tb_course.teacher_no = tb_teacher.`no`" +
            "and tb_student.id =#{id}"+"</script>")
    List<Map<String, String>> selectCourseById(@Param("id") Integer id);
}
